const { Sequelize, DataTypes } = require('sequelize');
const config = require('../config/config.js');
const sequelize = new Sequelize(config);

let userModel = sequelize.define(
	'user',
	{
		// 在这里定义模型属性
		username: {
			type: DataTypes.STRING,
			comment: '用户名'
		},
		nickname: {
			type: DataTypes.STRING,
			comment: '昵称'
		},
		password: {
			type: DataTypes.STRING,
			comment: '密码'
		},
		sex: {
			type: DataTypes.INTEGER,
			comment: '性别'
		},
		email: {
			type: DataTypes.STRING,
			comment: '邮箱'
		},
		portrait: {
			type: DataTypes.STRING,
			comment: '头像'
		},
		birthday: {
			type: DataTypes.STRING,
			comment: '生日'
		},
		phone: {
			type: DataTypes.STRING,
			comment: '手机号'
		},
		created_time: {
			type: Sequelize.INTEGER,
			comment: '注册时间',
			defaultValue: Date.parse(new Date()) / 1000
		},
		updated_time: {
			type: Sequelize.INTEGER,
			comment: '更新时间',
			defaultValue: Date.parse(new Date()) / 1000
		}
	},
	{
		// 这是其他模型参数
		timestamps: false,
		tableName: 'user'
	}
);

module.exports = userModel;
